#include <stdio.h>

// 指针变量
int main()
{
    int int1 = 7;          // 声明并初始化
    int *pointer1 = &int1; // 声明int类型的指针变量 pointer1 并存储变量int1的地址
    printf("int1: %d\n", int1);
    printf("指针pointer1: %d\n", *pointer1);
    int **pointer2 = &pointer1; // 声明一个二级指针 pointer2 并存储指针变量 pointer1的地址
    printf("指针pointer2: %d\n", **pointer2);
    int1++;
    printf("int1: %d\n", int1);
    printf("指针pointer1: %d\n", *pointer1);
    printf("指针pointer2: %d\n", **pointer2);
    // 指针数组是一个数组，其中的每个元素都是一个指针。
    int a = 10, b = 20, c = 30;
    int *arrPointer1[3] = {&a, &b, &c};
    printf("arrPointer1[0]: %d\n", *arrPointer1[0]);
    printf("arrPointer1[1]: %d\n", *arrPointer1[1]);
    printf("arrPointer1[2]: %d\n", *arrPointer1[2]);
    b++;
    printf("arrPointer1[1]: %d\n", *arrPointer1[1]);
    // 指针与函数
    int d = 10;
    printf("d: %d\n", d);
    void increment(int *p3)
    {
        (*p3)++;
    }
    increment(&d);
    printf("d: %d\n", d);
    return 0;
}